$(function () {
    $(".fill_name").change(function () {
        check_input(/^([\u4e00-\u9fa5]{1,20}|[a-zA-Z\.\s]{1,20})$/,$(this).val(),$(this));
    })
    $(".fill_card").change(function () {
        check_input(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,$(this).val(),$(this))
    })

    $(".fill_click").click(function () {
        if(/^([\u4e00-\u9fa5]{1,20}|[a-zA-Z\.\s]{1,20})$/.test($(".fill_name").val()) && /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test($(".fill_card").val())){
            $.ajax({
                url:"../../../front/php/fill.php",
                data: {name:$(".fill_name").val(),card:$(".fill_card").val()},
                dataType:"json",
                type:"GET",
                success:function (d) {
                    if(d.code == "S"){
                        window.location.href = "../index.html"
                    }
                }
            })
        }
    })
    function check_input(reg,val,that) {
        if(reg.test(val)){
            that.parent().parent().prop("class","weui-cell weui-cell_success").find("i").prop("class","weui-icon-success")
        }else{
            that.parent().parent().prop("class","weui-cell weui-cell_warn").find("i").prop("class","weui-icon-warn")
        };
    }
})